<?php

namespace App\Http\Controllers;

use App\Http\Requests\StudentCardCreate;
use App\Models\StudentCard;
use Illuminate\Http\Request;

class StudentCardController extends Controller
{
    public function create(StudentCardCreate $request)
    {

        $studentCard = $request->validated();
        $studentCard['school_id'] = $request->school_id;
        $studentCard['campus_id'] = $request->campus_id;
        $studentCard['residue'] = $request->total;
        $studentCard['status'] = 1;

        try{
            StudentCard::create($studentCard);
            return resSucc(null, "发卡成功");
        } catch (\Exception $e) {
            return resFail($e, "发卡失败");
        } catch (\Throwable $e) {
            return resFail($e, "发卡失败");
        }
    }
}
